﻿using System.Collections.Generic;
using System.Linq;
using HappyBa.Core.Data;
using HappyBa.Core.Interfaces;

namespace HappyBa.Core.Validators
{
    public class UnassignedEntities : IValidator
    {
        public IEnumerable<ValidationResult> Validate(ValidationContext context)
        {
            foreach (var entity in context.Metrics.Data.UserStories.Where(x => x.Release == null))
            {
                yield return new ValidationResult(
                    string.Format("'{0}': is not assigned for any release", entity))
                {
                    Entity = new UIEntityBase(entity, context.Metrics.Data)
                };
            }
            foreach (var entity in context.Metrics.Data.Bugs.Where(x => x.Release == null))
            {
                yield return new ValidationResult(
                    string.Format("'{0}': is not assigned for any release", entity))
                {
                    Entity = new UIEntityBase(entity, context.Metrics.Data)
                };
            }
        }
    }
}
